<template>
  <div class="work_block">
    <div class="title">
      <div class="des">待办</div>
      <div class="link">
        <el-link type="primary" @click="$router.push('work')">全部待办 ></el-link>
      </div>
    </div>
    <ul class="block">
      <li v-for="(work, index) in works" :key="index" @click="goDetail(work)">
        <div class="work_title">
          <i :class="work.bizType | getIcon" style="margin-right: 20px; font-size: 24px;"></i>
          <span>{{work.notifyContent}}</span>
        </div>
        <div>{{work.createTime}}</div>
      </li>
      <li v-if="!works.length">暂无数据</li>
    </ul>
  </div>
</template>
<script>
import httpSer from "@/http";
export default {
  data() {
    return {
      works: []
    };
  },
  created() {},
  mounted() {
    this.getWorks();
  },
  methods: {
    getWorks() {
      let url = "/userApproveTask/pageUserApproveTask";
      let data = {
        userTaskStatus: 1
      };
      httpSer.post(url, data).then(res => {
        let works = res.records;
        if (works.length > 5) {
          works.splice(0, 5);
        }

        this.works = works;
      });
    },
    goDetail(work) {
      let path = "";
      let query = {
        id: work.bizId,
        bizType: work.bizType,
        status: "approve",
        taskType: work.userTaskStatus
      };
      if (work.bizType == 1 || work.bizType == 2) {
        path = "project/projectDetail";
      } else if (work.bizType == 3) {
        path = "project/alterationDetail";
      } else if (work.bizType == 4) {
        path = "/task/taskApprove";
      } else if (work.bizType == 5) {
        path = "/task/taskDetail";
      } else {
        alert("未定义bizType");
      }
      this.$router.push({
        path,
        query: query
      });
    }
  },
  filters: {
    getIcon(bizType) {
      switch (bizType) {
        case 1:
          return "el-icon-circle-plus c_purple";
          break;
        case 2:
          return "el-icon-success c_green";
          break;
        case 3:
          return "el-icon-warning c_yellow";
          break;
        default:
          return "el-icon-info c_blue";
          break;
      }
    }
  },
  components: {}
};
</script>

<style lang="less" scope>
@import "./index.less";
</style>